﻿using System;
using visinia.SmartEngine;
using viWiki.Controllers;

public partial class Admin_Pages_viWiki_ManageWikiPages : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void GridViewPAGES_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
    {
        if (e.CommandName == "DeletePage")
        {
            int id = Convert.ToInt32(e.CommandArgument);            
            WikiPageController.DeleteWikiPage(id);            
            Response.Redirect(Request.RawUrl);
        }
    }

    public string GetLink(int pageid)
    {
        return SystemMenu.CallPage("viWiki", "EditPage", "WikiPageId", pageid.ToString());
    }

    public string GetNamespaceName(int NamespaceInfoId)
    {
        return NamespaceController.GetNamespace(NamespaceInfoId).Name;
    }

    public string GetImage(int WikiPageId)
    {
        if(WikiPageLinkController.GetOrphanWikiPages().Exists(p=> p.WikiPageId == WikiPageId))                
            return "Images/Orphan.png";
        return "Images/NonOrphan.gif";
    }

    protected void NEW_PAGE_Click(object sender, EventArgs e)
    {
        Response.Redirect(SystemMenu.CallPage("viWiki", "AddPage"));
    }
}
